﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using IronPython.Hosting;

namespace Lib
{
    public class PythonBoardBuilder
    {
        public IBoard BuildBoard()
        {
            Board b = new Board(6,7);
            var ironPythonRuntime = Python.CreateRuntime();
            dynamic loadIPython = ironPythonRuntime.UseFile(@"C:\Users\Fede\Documents\Facultad\IA\Obligatorio\Lib\bin\Debug\Lib\Translate.py");
            var tablero = loadIPython.listaNet();
            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    if (tablero[i + j*7] == 'a')
                    {
                        b.GetCell(i, j).AddPiece(new Pieces.APiece(true));
                    }
                    if (tablero[i + j * 7] == 'b')
                    {
                        b.GetCell(i, j).AddPiece(new Pieces.BPiece(true));
                    }
                    if (tablero[i + j * 7] == 'c')
                    {
                        b.GetCell(i, j).AddPiece(new Pieces.CPiece(true));
                    }
                    if (tablero[i + j * 7] == 'A')
                    {
                        b.GetCell(i, j).AddPiece(new Pieces.APiece(false));
                    }
                    if (tablero[i + j * 7] == 'B')
                    {
                        b.GetCell(i, j).AddPiece(new Pieces.BPiece(false));
                    }
                    if (tablero[i + j*7] == 'C')
                    {
                        b.GetCell(i, j).AddPiece(new Pieces.CPiece(false));
                    }
                }

            }
            
            return b;
        }
    }
}
